/*
 ------------------------------------------------------------------------------
	sdlmedia - a test program for a media search library, including test UI.

	Copyright (C) 2011 Pierre Veber
	
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software Foundation,
	Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
------------------------------------------------------------------------------
*/

#pragma once

/*	Media data handles. */
/*
 ------------------------------------------------------------------------------
	MediaFile_t
	Record for one track (media file).
	Collection stored as simple chained list.
------------------------------------------------------------------------------
*/

struct MediaFile_t
{
	char* pszFullPath;
	MediaInfo_t info;
	MediaDecoder_t* pDecoder;
	DecodeData_t* pDecodeData;
	struct MediaFile_t* pNext;
};

extern MediaFile_t* _gp_Current;

/*
 ------------------------------------------------------------------------------
	MediaLib_t
	One Media Library (relative to one root media folder).
	Collection stored as simple chained list.
------------------------------------------------------------------------------
*/

struct MediaLib_t
{
	char* pszPath;
	
	MediaFile_t* pHead;
	MediaFile_t* pTail;
	int nFiles;
	
	struct MediaLib_t* pNext;
};

/*	_walk needs to be defined as an external function, as it is platform-
	specific implementation. */
typedef int (*FoundFileProc)(void*, char*, char*);
int _walk(FastHeap_t* pHeap, char* pszBase, FoundFileProc fp, void* pData);

/*	MediaLib API. */
MediaLib_t*
	_media_lib_new(const char* pszPath);

void
	_media_lib_free(MediaLib_t* pLib);

int
	_media_lib_fill(MediaLib_t* pLib);

MediaFile_t*
	_media_lib_get_from_path(MediaLib_t* pLib, const char* pszFilePath);
